{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyspark import SparkContext\n",
    "from pyspark.sql import SparkSession"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "sc=SparkContext(appName=\"blaze_test\")      \n",
    "spark=SparkSession.builder.appName('blaze_test').master(\"Yct201811021847\").getOrCreate()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import blaze as bz\n",
    "from odo import odo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "rdd = bz.into(sc,\"category.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pyspark.rdd.RDD"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(rdd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "simple = bz.Data(rdd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "blaze.interactive._Data"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(simple)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(u'Seafood', 12L, 330L),\n",
       " (u'Meat/Poultry', 6L, 173L),\n",
       " (u'Condiments', 12L, 216L),\n",
       " (u'Confections', 13L, 334L),\n",
       " (u'Produce', 5L, 136L),\n",
       " (u'Dairy Products', 10L, 366L),\n",
       " (u'Beverages', 12L, 404L),\n",
       " (u'Grains/Cereals', 7L, 196L)]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simple.peek().collect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on Dispatcher in module multipledispatch.dispatcher object:\n",
      "\n",
      "into = class Dispatcher(__builtin__.object)\n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __call__(self, *args, **kwargs)\n",
      " |  \n",
      " |  __getstate__(self)\n",
      " |  \n",
      " |  __init__(self, name, doc=None)\n",
      " |  \n",
      " |  __repr__ = __str__(self)\n",
      " |  \n",
      " |  __setstate__(self, d)\n",
      " |  \n",
      " |  __str__(self)\n",
      " |  \n",
      " |  add(self, signature, func)\n",
      " |      Add new types/method pair to dispatcher\n",
      " |      \n",
      " |      >>> D = Dispatcher('add')\n",
      " |      >>> D.add((int, int), lambda x, y: x + y)\n",
      " |      >>> D.add((float, float), lambda x, y: x + y)\n",
      " |      \n",
      " |      >>> D(1, 2)\n",
      " |      3\n",
      " |      >>> D(1, 2.0)\n",
      " |      Traceback (most recent call last):\n",
      " |      ...\n",
      " |      NotImplementedError: Could not find signature for add: <int, float>\n",
      " |      \n",
      " |      When ``add`` detects a warning it calls the ``on_ambiguity`` callback\n",
      " |      with a dispatcher/itself, and a set of ambiguous type signature pairs\n",
      " |      as inputs.  See ``ambiguity_warn`` for an example.\n",
      " |  \n",
      " |  dispatch(self, *types)\n",
      " |      Deterimine appropriate implementation for this type signature\n",
      " |      \n",
      " |      This method is internal.  Users should call this object as a function.\n",
      " |      Implementation resolution occurs within the ``__call__`` method.\n",
      " |      \n",
      " |      >>> from multipledispatch import dispatch\n",
      " |      >>> @dispatch(int)\n",
      " |      ... def inc(x):\n",
      " |      ...     return x + 1\n",
      " |      \n",
      " |      >>> implementation = inc.dispatch(int)\n",
      " |      >>> implementation(3)\n",
      " |      4\n",
      " |      \n",
      " |      >>> print(inc.dispatch(float))\n",
      " |      None\n",
      " |      \n",
      " |      See Also:\n",
      " |        ``multipledispatch.conflict`` - module to determine resolution order\n",
      " |  \n",
      " |  dispatch_iter(self, *types)\n",
      " |  \n",
      " |  help(self, *args, **kwargs)\n",
      " |      Print docstring for the function corresponding to inputs\n",
      " |  \n",
      " |  register(self, *types, **kwargs)\n",
      " |      register dispatcher with new implementation\n",
      " |      \n",
      " |      >>> f = Dispatcher('f')\n",
      " |      >>> @f.register(int)\n",
      " |      ... def inc(x):\n",
      " |      ...     return x + 1\n",
      " |      \n",
      " |      >>> @f.register(float)\n",
      " |      ... def dec(x):\n",
      " |      ...     return x - 1\n",
      " |      \n",
      " |      >>> @f.register(list)\n",
      " |      ... @f.register(tuple)\n",
      " |      ... def reverse(x):\n",
      " |      ...     return x[::-1]\n",
      " |      \n",
      " |      >>> f(1)\n",
      " |      2\n",
      " |      \n",
      " |      >>> f(1.0)\n",
      " |      0.0\n",
      " |      \n",
      " |      >>> f([1, 2, 3])\n",
      " |      [3, 2, 1]\n",
      " |  \n",
      " |  reorder(self, on_ambiguity=<function ambiguity_warn>)\n",
      " |  \n",
      " |  resolve(self, types)\n",
      " |      Deterimine appropriate implementation for this type signature\n",
      " |      \n",
      " |      .. deprecated:: 0.4.4\n",
      " |          Use ``dispatch(*types)`` instead\n",
      " |  \n",
      " |  source(self, *args, **kwargs)\n",
      " |      Print source code for the function corresponding to inputs\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Class methods defined here:\n",
      " |  \n",
      " |  get_func_annotations(cls, func) from __builtin__.type\n",
      " |      get annotations of function positional parameters\n",
      " |  \n",
      " |  get_func_params(cls, func) from __builtin__.type\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Data descriptors defined here:\n",
      " |  \n",
      " |  doc\n",
      " |  \n",
      " |  funcs\n",
      " |  \n",
      " |  name\n",
      " |  \n",
      " |  ordering\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(bz.into)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function data in module blaze.interactive:\n",
      "\n",
      "data(data_source, dshape=None, name=None, fields=None, schema=None, **kwargs)\n",
      "    Bind a data resource to a symbol, for use in expressions and\n",
      "    computation.\n",
      "    \n",
      "    A ``data`` object presents a consistent view onto a variety of concrete\n",
      "    data sources.  Like ``symbol`` objects, they are meant to be used in\n",
      "    expressions.  Because they are tied to concrete data resources, ``data``\n",
      "    objects can be used with ``compute`` directly, making them convenient for\n",
      "    interactive exploration.\n",
      "    \n",
      "    Parameters\n",
      "    ----------\n",
      "    data_source : object\n",
      "        Any type with ``discover`` and ``compute`` implementations\n",
      "    fields : list, optional\n",
      "        Field or column names, will be inferred from data_source if possible\n",
      "    dshape : str or DataShape, optional\n",
      "        DataShape describing input data\n",
      "    name : str, optional\n",
      "        A name for the data.\n",
      "    \n",
      "    Examples\n",
      "    --------\n",
      "    >>> t = data([(1, 'Alice', 100),\n",
      "    ...           (2, 'Bob', -200),\n",
      "    ...           (3, 'Charlie', 300),\n",
      "    ...           (4, 'Denis', 400),\n",
      "    ...           (5, 'Edith', -500)],\n",
      "    ...          fields=['id', 'name', 'balance'])\n",
      "    >>> t[t.balance < 0].name\n",
      "        name\n",
      "    0    Bob\n",
      "    1  Edith\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(bz.data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function symbol in module blaze.expr.expressions:\n",
      "\n",
      "symbol(name, dshape, token=None)\n",
      "    Symbolic data.  The leaf of a Blaze expression\n",
      "    \n",
      "    Examples\n",
      "    --------\n",
      "    >>> points = symbol('points', '5 * 3 * {x: int, y: int}')\n",
      "    >>> points\n",
      "    <`points` symbol; dshape='5 * 3 * {x: int32, y: int32}'>\n",
      "    >>> points.dshape\n",
      "    dshape(\"5 * 3 * {x: int32, y: int32}\")\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(bz.symbol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
